import QtQuick
import QtQuick.Particles

Rectangle {
    width: 400
    height: 400
    color: "black"

    ParticleSystem {
        id: particleSystem
    }

    ItemParticle {
        system: particleSystem
        delegate: Rectangle {
            width: 4
            height: 4
            color: "cyan"
            radius: 2
        }
    }

    // 移动的发射器
    Emitter {
        id: sourceEmitter
        system: particleSystem
        enabled: true
        size: 4

        // X轴动画
        SequentialAnimation on x {
            loops: Animation.Infinite
            NumberAnimation {
                from: 50
                to: 350
                duration: 2000
                easing.type: Easing.InOutQuad
            }
            NumberAnimation {
                from: 350
                to: 50
                duration: 2000
                easing.type: Easing.InOutQuad
            }
        }

        // Y轴动画
        SequentialAnimation on y {
            loops: Animation.Infinite
            NumberAnimation {
                from: 50
                to: 350
                duration: 3000
                easing.type: Easing.InOutSine
            }
            NumberAnimation {
                from: 350
                to: 50
                duration: 3000
                easing.type: Easing.InOutSine
            }
        }
    }

    // 可视化发射器位置
    Rectangle {
        x: sourceEmitter.x - width/2
        y: sourceEmitter.y - height/2
        width: 10
        height: 10
        radius: 5
        color: "white"
    }

    Text {
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        color: "white"
        text: "运动的粒子轨迹"
        font.pixelSize: 16
        padding: 10
    }
} 
